var t = getApp(), a = require("../../../utils/themeSkin/skinBehavior");

Page({
    behaviors: [ a ],
    data: {
        credit1: 0,
        transfer: !1,
        activity: !1,
        integral: "",
        transfer_integral: !1,
        transfer_integral_text: "",
        loveByMember: 0,
        consumption_integral: "",
        love: "",
        page: 1,
        isLoadMore: !0,
        total_page: 0
    },
    onLoad: function(t) {
        this._getIntegral();
        try {
            var a = wx.getStorageSync("integral"), e = wx.getStorageSync("yz_basic_info").integral;
            e && this.setData({
                consumption_integral: e
            }), a && (this.setData({
                integral: a
            }), this.data.integral && wx.setNavigationBarTitle({
                title: this.data.integral
            }));
        } catch (t) {}
        var n = wx.getStorageSync("yz_basic_info");
        this.setData({
            love: n.love
        }), console.log(n);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {},
    showTap: function() {
        this.setData({
            show: !0
        });
    },
    showClose: function() {
        this.setData({
            show: !1
        });
    },
    jumpUrlBtn: function(t) {
        var a = t.currentTarget.dataset.item;
        1 == a.type ? wx.navigateTo({
            url: a.mini_url,
            fail: function(t) {
                wx.reLaunch({
                    url: a.mini_url
                });
            }
        }) : 2 == a.type ? a.poster_id : 3 == a.type ? wx.navigateTo({
            url: "/packageA/member/editmobile/editmobile"
        }) : wx.navigateTo({
            url: a.mini_url,
            fail: function(t) {
                wx.reLaunch({
                    url: a.mini_url
                });
            }
        });
    },
    tapOther: function(t) {
        var a = t.currentTarget.dataset.index;
        "activity" == a ? this.toIntegral() : "transfer_integral" == a ? this.to_transfer_integral() : "exchange_to_love_by_member" == a ? this.to_transfer_love() : "point_exchange" == a && this.point_exchange();
    },
    point_exchange: function() {
        wx.navigateTo({
            url: "/packageI/Intergral_transform/Intergral_transform"
        });
    },
    getTaskList: function() {
        var a = this;
        t._postNetWork({
            url: t.getNetAddresss("plugin.point-task.api.task.index"),
            success: function(t) {
                t.data.result && (a.setData({
                    listIncome: t.data.data.income,
                    list: t.data.data.list,
                    integralTaskName: t.data.name ? t.data.name : "积分任务"
                }), a.data.isLoadMore = !0, a.data.total_page = t.data.last_page, a.data.total_page || (a.data.total_page = 0));
            }
        });
    },
    getMoreData: function() {
        var a = this, e = "";
        this.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        e = t.getNetAddresss("plugin.point-task.api.task.index"), t._postNetWork({
            url: e,
            data: {
                page: this.data.page
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.data.isLoadMore = !0, a.setData({
                    list: a.data.list.concat(e.data.data.list)
                })) : (a.data.page = a.data.page - 1, a.isLoadMore = !1, wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        }));
    },
    _getIntegral: function() {
        var a = this, e = t.getNetAddresss("finance.point-page.index");
        t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.setData({
                    credit1: e.data.credit1,
                    transfer: e.data.transfer,
                    transfer_integral: e.data.transfer_integral,
                    dataList: e.data.latest_record,
                    other: e.data.other,
                    point_task_switch: e.data.point_task_switch
                }), e.data.point_task_switch && a.getTaskList(), e.data.other.exchange_to_love_by_member && (a.data.loveByMember = 1), 
                1 == e.data.activity ? a.setData({
                    activity: !0
                }) : a.setData({
                    activity: !1
                }), wx.setNavigationBarColor({
                    frontColor: "#ffffff",
                    backgroundColor: a.data.themeBaseColor,
                    animation: {
                        duration: 400,
                        timingFunc: "easeIn"
                    }
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    transferHandel: function() {
        this.data.transfer ? wx.navigateTo({
            url: "/packageB/member/integral_transfer/integral_transfer?integral=" + this.data.credit1
        }) : wx.showToast({
            icon: "none",
            title: "您的转账功能未开启",
            duration: 1500
        });
    },
    to_transfer_integral: function() {
        wx.navigateTo({
            url: "/packageB/member/transfer_integral/transfer_integral"
        });
    },
    to_transfer_love: function() {
        wx.navigateTo({
            url: "/packageB/member/transfer_integral/transfer_integral?loveByMember=".concat(this.data.loveByMember)
        });
    },
    toIntegral: function() {
        wx.navigateTo({
            url: "/packageB/member/IntegralActivity/IntegralActivity?integral=" + this.data.credit1
        });
    },
    integralgolist: function() {
        wx.navigateTo({
            url: "/packageB/member/integrallist/integrallist"
        });
    }
});